<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
        <link href="./resources/css/estilos.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
         <h:outputLink  id="loginLink" value="javascript:void(0)" onclick="dlg.show()" title="Bienvenido EVC - Rubber International">     
        <p:graphicImage id="centrar" value="/resources/img/login.png" />  
        </h:outputLink>  
        
        <p:growl id="growl" showDetail="true" life="3000" />  
  
<p:dialog id="dialog" header="Bienvenido" widgetVar="dlg">  
    <h:form>  
  
        <h:panelGrid columns="2" cellpadding="5">  
            <h:outputLabel value="Nombre de Usuario:" />  
            <p:inputText value="#{LoginBean.usuario}"   
                         id="username" required="true" requiredMessage="LLene el campo username" />  
              
            <h:outputLabel value="Contraseña:" />  
            <h:inputSecret value="#{LoginBean.contraseña}"   
                           id="password" required="true" requiredMessage="Debe llenar el campo contraseña" label="password" />   
            
        </h:panelGrid> 
        <p:separator/> 
        <h:panelGrid columns="2" cellpadding="5">
                <p:commandButton id="loginButton" value="ingresar" update=":growl"   
                                 actionListener="#{LoginBean.login}"   
                    oncomplete="handleLoginRequest(xhr, status, args)"/>  
     
        </h:panelGrid>
          
    </h:form>  
</p:dialog>  
        
        
        <script type="text/javascript">  
    function handleLoginRequest(xhr, status, args) {  
        if(args.validationFailed || !args.loggedIn) {  
            jQuery('#dialog').effect("shake", { times:3 }, 100);  
        } else {  
            dlg.hide();  
            jQuery('#loginLink').fadeOut();  
            window.location="/EVC_RI/Inicio.jsf"
        }  
    }  
</script>
    </h:body>
</html>

